package com.yzt.zhuju.dialog1;

import android.app.Dialog;
import android.content.Context;
import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.os.Bundle;
import android.view.Window;
import android.view.WindowManager;

import androidx.annotation.LayoutRes;

//import butterknife.ButterKnife;

/**
 * <pre>
 *     author : TK
 *     desc   : 基类Dialog
 * </pre>
 */
public abstract class BaseDialog extends Dialog {

    public BaseDialog(Context context) {
        super(context);
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        //背景透明
        getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
        //窗口之后的内容变暗。
        getWindow().addFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);
        setCanceledOnTouchOutside(true);
        setCancelable(true);
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(layoutId());
        //ButterKnife.bind(this);
        onContentViewSet();
    }

    @LayoutRes
    protected abstract int layoutId();

    protected abstract void onContentViewSet();

}
